class Solution(object):
    def minimumRemoval(self, beans):
        beans.sort()
        t = sum(beans)
        n = len(beans)
        max_val = -float('inf')
        for i in range(n):
            max_val = max(max_val, (n - i) * beans[i])
        return t - max_val
